<?php
/**
 * Created by PhpStorm.
 * User: wodrow
 * Date: 18-3-13
 * Time: 上午10:15
 */

namespace common\models\credit_app;

/**
 * Class OrderOwner
 * @package common\models\credit_app
 *
 * @property Order $order
 */
class OrderOwner extends \common\models\credit_app_tables\OrderOwner
{
    public function rules()
    {
        return [
            [['ot_oid', 'ot_residence_pro', 'ot_residence_city', 'ot_residence_area', 'ot_edu', 'ot_mobile', 'ot_married', 'ot_bankcard', 'ot_liveadd', 'ot_tel', 'ot_home_add', 'ot_house_add', 'ot_house_owner', 'ot_hown_relation', 'ot_house_nature', 'ot_house_acreage', 'ot_house_price', 'ot_house_loyear', 'ot_company_add', 'ot_company_tel', 'ot_company_type', 'ot_duty_type', 'ot_duty', 'ot_operat_period', 'ot_seniority', 'ot_stake', 'ot_income_month', 'ot_contact', 'ot_remark', 'ot_status', 'ot_dateline', 'ot_checkin_date', 'ot_hiredate'], 'required'],
            [['ot_oid', 'ot_dateline'], 'integer'],
            [['ot_house_acreage', 'ot_house_price', 'ot_house_loan', 'ot_house_refundmo', 'ot_stake', 'ot_income_month'], 'number'],
            [['ot_contact', 'ot_status'], 'string'],
            [['ot_residence_pro', 'ot_residence_city', 'ot_residence_area', 'ot_edu', 'ot_bankcard', 'ot_tel', 'ot_house_owner', 'ot_hown_relation', 'ot_house_nature', 'ot_company', 'ot_company_type', 'ot_duty_type', 'ot_duty', 'ot_operat_period', 'ot_seniority'], 'string', 'max' => 30],
            [['ot_mobile', 'ot_married', 'ot_house_loyear', 'ot_company_tel'], 'string', 'max' => 20],
            [['ot_liveadd', 'ot_company_add'], 'string', 'max' => 50],
            [['ot_home_add', 'ot_house_add'], 'string', 'max' => 100],
            [['ot_remark'], 'string', 'max' => 255],
            [['ot_house_loan', 'ot_house_refundmo'], 'default', 'value' => '0.00'],
        ];
    }

    public static $serialize_fields = [
        'ot_contact',
    ];

    /**
     * @param $id
     * @return null|static
     */
    public static function findActiveOneById($id)
    {
        return static::findOne(['ot_id'=>$id]);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getOrder()
    {
        return $this->hasOne(Order::className(), ['o_id' => 'ct_oid']);
    }
}